<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>点击</button>
    <div></div>
    <script>
        var btn = document.querySelector('button');
        var div = document.querySelector('div');
        var time = 5;
        var timer = null
        btn.addEventListener('click', function () {
            btn.disabled = true;
            skip() //先调用一次，防止刷新有空白
           timer = setInterval(skip, 1000)
            function skip() {
                if (time == 0) {
                    location.href = 'http://www.baidu.com'
                    clearInterval(timer);
                    btn.disabled = false;
                    time = 5;
                } else {
                    div.innerText = '您将在' + time + '秒后跳转到百度首页';
                    time--;
                }
            }
        })

    </script>
</body>

</html>